#ifndef _CASMSCTRL_H
#define _CASMSCTRL_H

#include "ASmsCtrl.h"

class CASmsCtrl
{
public:
	CASmsCtrl(const WCHAR* szDevice = NULL, int baudRate = 9600);
	~CASmsCtrl(void);

	typedef DWORD WINAPI TProcReceive(WCHAR* szSender, WCHAR* szMsg);

public:
	bool Init();

	bool TestReady();

	void SetDevice(const WCHAR* szDevice); 

	bool Send(const WCHAR* szNumber, const WCHAR* szMsg );

	void Receive(TProcReceive proc);

	BSTR GetNextDevice();

private:
	static DWORD WINAPI proc_receive(LPVOID lpVoid);


	LONG get_last_error( bool bReceive );

	bool com_exists(const WCHAR* com);


private:
	IGsmOut		* m_pGsmOut;
	IGsmIn		* m_pGsmIn;

	WCHAR m_szDevice[MAX_PATH];

	WCHAR m_szResult[MAX_PATH];

	int m_baudRate;

	bool m_bStop;

	bool m_bReceiving;

};

#endif
